using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace TestModels.Models.Mapping
{
    public class OrderMap : EntityTypeConfiguration<Order>
    {
        public OrderMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Status)
                .IsFixedLength()
                .HasMaxLength(10);

            this.Property(t => t.OrderNum)
                .HasMaxLength(50);

            this.Property(t => t.OrderInfo)
                .HasMaxLength(200);

            this.Property(t => t.Address)
                .HasMaxLength(200);

            this.Property(t => t.Tel)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Order");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Created).HasColumnName("Created");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.SellerID).HasColumnName("SellerID");
            this.Property(t => t.OrderNum).HasColumnName("OrderNum");
            this.Property(t => t.OrderMoney).HasColumnName("OrderMoney");
            this.Property(t => t.SellerTime).HasColumnName("SellerTime");
            this.Property(t => t.UserTime).HasColumnName("UserTime");
            this.Property(t => t.OrderInfo).HasColumnName("OrderInfo");
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.Tel).HasColumnName("Tel");
        }
    }
}
